<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>FormLayout 表单布局</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

    
    <script src="__PUBLIC__/scripts/boot.js" type="text/javascript"></script>
    
    
    <style type="text/css">
     .td1
    {
        text-align:right;
    }
    .td2
    {
        padding-left:15px;
        font-size:13px;
        font-family:Tahoma;
    }
        fieldset
    {
        border:solid 1px #aaa;
    }        
    .hideFieldset
    {
        border-left:0;
        border-right:0;
        border-bottom:0;
    }
    .hideFieldset .fieldset-body
    {
        display:none;
    } 
       
    </style>

</head>
<body>
    <h1>项目信息 </h1>  
<div style="width: 900px;">
<div class="mini-toolbar" style="border-bottom: 0; padding: 2px;">
<table style="width: 100%;">
	<tr>
		<td style="width: 100%;"><a class="mini-button"
			iconCls="icon-add" onclick="showWindow()">修改</a></td>
		<td style="white-space: nowrap;"></td>
	</tr>
</table>
</div>
</div>
<div id="form0" style="width: 904px;">
<fieldset> 
        <legend>项目基本信息</legend>
        <table>
            <tr>
                <td class="td1">
                    <label for="pno$text" >项目编号 </label>
                </td>
                <td id="label_pno">
                    {$list["pno"]}
                </td>       
            </tr>
              <tr>
                <td class="td1">
                    <label for="pname$text" >项目名称 </label>
                </td>
                <td id="label_pname">
                    {$list["pname"]}
                </td>
            </tr>
              <tr>
                <td class="td1">
                    <label for="date$text">入库时间 </label>
                </td>
                <td id="label_regdate">
                    {$list["regdate"]}
                </td>
            </tr>
            <tr>
            	<td class="td1">
            		<label for="state">状态 </label>
            	</td>
            	<td id="label_state">
            		{$list["state"]}
           	</td>
            </tr>
     </table> 
   </fieldset>          
	 <fieldset> 
        <legend>项目组信息</legend> 
        
        <table>
            <tr>
                <td class="td1">
                   <label for="source">项目来源</label> 
                </td>
                <td id="label_source">
                   {$list["source"]}
                </td>  
                <td class="td1">
                   <label for="fund">拟投基金主体</label> 
                </td>
                <td id="label_fund">
      
					{$list["fund"]}
                  
                </td>         
            </tr>
              <tr>
                <td class="td1">
                    <label for="partnername">合伙人</label> 
                </td>
                <td id="label_partnername">
					{$list["partnername"]}
                    
                </td>
                <td class="td1">
                   <label for="managername">项目经理</label> 
                </td>
                <td id="label_managername">
				{$list["managername"]}
                   
                        </td>       
            </tr>
              <tr>
                <td class="td1">
                   <label for="membername">项目组成员</label> 
                </td>
                <td id="label_membername">
				{$list["membername"]}
				   
                    
                </td>
            </tr>
     </table>
     
        
           
    </fieldset> 
    <fieldset> 
    	 <legend>项目公司基本信息</legend>
          
          <table>
            <tr>
                <td class="td1">
                   <label for="cname" >公司名称 </label>
                </td>
                <td id="label_cname">
                  {$list["cname"]}
                </td>       
            </tr>
              <tr>
                <td class="td1">
                    <label for="address" >公司地址 </label> 
                </td>
                <td id="label_address">
                  {$list["address"]}
                </td>
            </tr>
              <tr>
                <td class="td1">
                   <label for="classify" >所属行业 </label> 
                </td>
                <td id="label_classify">
                    {$list["classify"]}
                </td>
            </tr>
     </table>
    
    </fieldset> 

    <fieldset> 
    	 <legend>公司联系人信息</legend>
         <table>
            <tr>
                <td class="td1">
                   <label for="contact_name" >姓名 </label> 
                </td>
				 <td id="label_contact_name">
                  {$list["contact_name"]}
                </td>       
            </tr>
          <tr>
                <td class="td1">
                  <label for="contact_position" >职位 </label> 
                </td>
				 <td id="label_contact_position">
                   {$list["contact_position"]}
                </td>       
            </tr>
			<tr>
                <td class="td1">
                <label for="contact_phone" >电话 </label> 
                </td>
				 <td id="label_contact_phone">
                 {$list["contact_phone"]}
                </td>       
            </tr>
			<tr>
                <td class="td1">
                <label for="contact_email" >邮箱 </label>
                </td>
				 <td id="label_contact_email">
                {$list["contact_email"]}
                </td>       
            </tr>
			     </table>
                      
    </fieldset> 
    
    <fieldset> 
        <legend>项目介绍</legend> 
		<table>		     
				<tr>
                <td class="td1">
                 <label for="intro#text">描述  </label> 
                </td>
				 <td id="label_intro">
                {$list["intro"]}
                </td>       
            </tr>
		</table>
           
    </fieldset> 
     
</div><!--form0 -->


 <div id="win1" class="mini-window" title="详细内容" style="width: 800px;"
	showMaxButton="true" showToolbar="true" showFooter="true"
	showModal="true" allowResize="true" allowDrag="true">  
 <div id="form1">  

<fieldset> 
        <legend>项目基本信息</legend>
        <table>
            <tr>
                <td class="td1">
                    <label for="pno$text" >项目编号 </label>
                </td>
                <td >
                    <input class="mini-textbox"  id="pno" required="true" type="text" name="pno" value=""  readonly="true"/>
                </td>       
            </tr>
              <tr>
                <td class="td1">
                    <label for="pname$text" >项目名称 </label>
                </td>
                <td >
                    <input class="mini-textbox"  id="pname" required="true" type="text" name="pname" value=""  readonly="true"/>
                </td>
            </tr>
              <tr>
                <td class="td1">
                    <label for="date$text">入库时间 </label>
                </td>
                <td >
                    <input class="mini-datepicker" id="regdate" required="true" name="regdate" format="yyyy-MM-dd" />
                </td>
            </tr>
            <tr>
            	<td class="td1">
            		<label for="state">状态 </label>
            	</td>
            	<td>
            		<input name="state" id="state" showNullItem="true" required="true" class="mini-combobox" url="__PUBLIC__/data/state.txt"   value=""  textField="text" valueField="id" />
           	</td>
            </tr>
     </table> 
            
	
      </fieldset> 
     <fieldset> 
        <legend>项目组信息</legend> 
        
        <table>
            <tr>
                <td class="td1">
                   <label for="source">项目来源</label> 
                </td>
                <td >
                   <input  class="mini-textbox" id="source" type="text" name="source" value="" style="width:200px;" />
                </td>  
                <td class="td1">
                   <label for="fund">拟投基金主体</label> 
                </td>
                <td >
      
		<input name="fund" showNullItem="true" class="mini-combobox" url="__APP__/Filter/fund" value="" textField="text" valueField="text" />
                  
                </td>         
            </tr>
              <tr>
                <td class="td1">
                    <label for="partnername">合伙人</label> 
                </td>
                <td >
                     <input   class="mini-autocomplete" required="true" style="width:200px;"
    		valueField="text" textField="text" textName="partnername" name="partnername"
        url="__APP__/Filter/username"  >  
                </td>
                <td class="td1">
                   <label for="managername">项目经理</label> 
                </td>
                <td >
                    <input   class="mini-autocomplete" required="true" style="width:200px;"
    		valueField="text" textField="text" textName="managername" name="managername"
        url="__APP__/Filter/username"  >  
                        </td>       
            </tr>
              <tr>
                <td class="td1">
                   <label for="membername">项目组成员</label> 
                </td>
                <td >
				    <input id="lookup2" name="membername" class="mini-lookup" style="width:200px;" 
        textField="nickname" valueField="nickname" popupWidth="auto"
        popup="#gridPanel" grid="#datagrid1" multiSelect="true" />
                    
                </td>
            </tr>
     </table>
     
        
           
    </fieldset> 
    <fieldset> 
    	 <legend>项目公司基本信息</legend>
          
          <table>
            <tr>
                <td class="td1">
                   <label for="cname" >公司名称 </label>
                </td>
                <td >
                   <input class="mini-textbox"  id="cname" type="text" required="true" name="cname" value=""  width="450px"/>
                </td>       
            </tr>
              <tr>
                <td class="td1">
                    <label for="address" >公司地址 </label> 
                </td>
                <td >
                   <input  class="mini-textbox" id="address" type="text" name="address" value="" width="450px" />
                </td>
            </tr>
              <tr>
                <td class="td1">
                   <label for="classify" >所属行业 </label> 
                </td>
                <td >
                   <input name="classify" showNullItem="true" class="mini-combobox" url="__APP__/Filter/industry" value="" textField="text" valueField="text" />
                  
                </td>
            </tr>
     </table>
    
    </fieldset> 

    <fieldset> 
    	 <legend>公司联系人信息</legend>
        
          <div><label for="contact_name" >姓名 </label> <input class="mini-textbox"  required="true" id="contact_name" type="text" name="contact_name" value=""  />
             </div> 
          <div><label for="contact_position" >职位 </label> <input class="mini-textbox"  required="true" id="contact_position" type="text" name="contact_position" value=""  />
             </div>
          <div><label for="contact_phone" >电话 </label> <input class="mini-textbox" required="true" onvalidation="onPhoneValidation" id="contact_phone"  type="text" name="contact_phone" value=""  />
             </div>
             <div><label for="contact_email" >邮箱 </label> <input class="mini-textbox"  id="contact_email" type="text" name="contact_email" value=""  />
             </div>  
                      
    </fieldset> 
    
    <fieldset> 
        <legend>项目介绍</legend> 
            <div> 
                <label for="intro#text">描述  </label> 
                <textarea class="mini-textarea"  id="desc" name="intro" width="100%" ></textarea> 
            </div> 
           
    </fieldset> 
    
   
   	<br />
		
		
	<input value="更新" type="button" onclick="updateForm()" />
	<input value="还原" type="button" onclick="loadForm()" />
	
		
  </div>  
  
  <div id="gridPanel" class="mini-panel" title="header" iconCls="icon-add" style="width:450px;height:250px;" 
        showToolbar="true" showCloseButton="true" showHeader="false" bodyStyle="padding:0" borderStyle="border:0" 
    >
        <div property="toolbar" style="padding:5px;padding-left:8px;text-align:center;">   
            <span>姓名：</span>    
            <input id="keyText" class="mini-textbox" style="width:160px;" onenter="onSearchClick"/>
            <a class="mini-button" onclick="onSearchClick">查询</a>
            <a class="mini-button" onclick="onCloseClick">关闭</a>
        </div>
        <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" 
            borderStyle="border:0" showPageSize="false" showPageIndex="false"
            url="__APP__/User/query" pageSize="50" 
        >
            <div property="columns">
                <div type="checkcolumn" >#</div>   
                <div field="nickname" width="120" headerAlign="center" allowSort="true">姓名</div>                     
            </div>
        </div>  
    </div>
	
	</div>

    <script type="text/javascript">
        mini.parse();
		var grid = mini.get("datagrid1");
        var keyText = mini.get("keyText");
        var olddata;
        grid.load();
		loadForm();
		
		
		
		grid.on("beforecloseclick", function (e) {
              alert("1");//弹个ID出来就好了	
			 
         });
		 
		 
		 
         function updateForm() {
			//提交表单数据
			if(checkauth()){
            var form = new mini.Form("#form1");            
            var data = form.getData();      //获取表单多个控件的数据
            form.validate();
            if (form.isValid() == false) return;
            //var json = mini.encode(data);   //序列化成JSON
            $.ajax({
                url: "__APP__/Project/update",
                type: "post",
                data: { Data: data },
                success: function (text) {
                    alert("提交成功");
 					form.setData(data);   //设置多个控件数据
                    olddata = form.getData();       
					$("#label_state").html(data.state);				
					$("#label_source").html(data.source);				
					$("#label_fund").html(data.fund);				
					$("#label_partnername").html(data.partnername);				
					$("#label_managername").html(data.managername);				
					$("#label_membername").html(data.membername);				
					$("#label_cname").html(data.cname);				
					$("#label_address").html(data.address);				
					$("#label_classify").html(data.classify);				
					$("#label_contact_name").html(data.contact_name);				
					$("#label_contact_position").html(data.contact_position);				
					$("#label_contact_phone").html(data.contact_phone);				
					$("#label_contact_email").html(data.contact_email);				
					$("#label_intro").html(data.intro);				
									
                }
            });
			}
        }
		function loadForm() {
            //加载表单数据
            var form = new mini.Form("#form1");     
			var form0 = new mini.Form("#form0");
			//var pid = document.getElementById("pid").value;
			//mini.alert(pid);
            $.ajax({
                url: "__APP__/Project/select",
                type: "post",
                success: function (text) {
					var data = mini.decode(text);
					 if(data['error'])
                      	mini.alert("尚未选择项目！","提示",function(){window.CloseOwnerWindow('refresh');});
                    
                       //反序列化成对象
                    form.setData(data);   //设置多个控件数据
					form0.setData(data);
                    olddata = form.getData();         
                }
            });
        }
		function getForm() {
			//提交表单数据
            var form = new mini.Form("#form1");  
            form.validate();
            if (form.isValid() == false) return;
			
            var data = form.getData();      //获取表单多个控件的数据
            var json = mini.encode(data);   //序列化成JSON
			mini.alert(json);
        }
		
		function resetForm() {
            var form = new mini.Form("#form1");
            form.reset();
        }
		 function onSearchClick(e) {
            grid.load({
                key: keyText.value
            });
        }
        function onCloseClick(e) {
            var lookup2 = mini.get("lookup2");
            lookup2.hidePopup();
        }
        function getData(){
		var form = new mini.Form("#form1");
            var data = form.getData();
            var json1 = mini.encode(data); 
            //alert(json1);
            var json2 = mini.encode(olddata);
            //alert(json2);
            if(json1!=json2)        
            	return "已经改变内容，尚未提交，";
            else 
            	return "无变化";

       	}
       	function CloseWindow(action) {

        if (window.CloseOwnerWindow) window.CloseOwnerWindow(action);

        else window.close();

    	} 
    	function checkauth() {
				var uname = "{$_SESSION['nickname']}";
				var mname = "{$_SESSION['membername']}";
				var depart = "{$_SESSION['depart']}";
				var pos = mname.indexOf(uname);
				if(pos == -1 && depart != "营运" && uname != "{$_SESSION['managername']}") {
					mini.alert("无操作权限！");
					return false;
				} else
					return true;
			}
  
		function onPhoneValidation(e){
            if (e.isValid) {
                if (isPhone(e.value) == false) {
                    e.errorText = "必须输入电话号码（数字或者下划线）";
                    e.isValid = false;
                }
            }
        }
        function isPhone(v) {
            var re = new RegExp("^[0-9\-]+$");
            if (re.test(v)) return true;
            return false;
        }
		function showWindow() {
		var win = mini.get("win1");
		win.show();
	}
    </script>

   
</body>
</html>